<div class="page-header">
    <h1>Detalhes <small>Cliente</small></h1>
</div>


<ul class="breadcrumb">
  <li><a href="<?php echo $this->baseUrl() ?>/index">Home</a> <span class="divider">/</span></li>
  <li><a href="<?php echo $this->baseUrl() ?>/cliente/listar">Listar Clientes</a> <span class="divider">/</span></li>
  <li class="active">Detalhes do Cliente</li>
</ul>

<div class="container-fluid">
    <div class="row-fluid" id="loja-show-div-controle">
        <div class="span8">
            <div class="row-fluid" id="loja-show-info">
                <div class="span4">
                    <p style="text-align: right">Nome:</p>
                    <p style="text-align: right">CPF:</p>
                </div>
                <div class="span7">
                    <p><?php echo $this->cliente->nome?></p>
                    <p><?php echo $this->cliente->cpf?></p>
                </div>
            </div>
        </div>
        <div class="span4">
            <?php if ($this->session->role == Role::ADMINISTRADOR): ?>
            <a href="#modal-cadastrar-emprestimo" role="button" data-toggle="modal"><button class="btn btn-large btn-default" title="Adicionar Empréstimo"><img src="<?php echo $this->baseUrl() ?>/public/img/add2.png" width="30" height="30"/></button></a>
            <?php endif; ?>
        </div>
    </div>
    <div class="row-fluid" style="margin-top: 20px;">
        <div class="span2"></div>
        <div class="span8">
            <div class="accordion" id="accordion-1000">
                
                <?php foreach ($this->emprestimos as $emprestimo): ?>

                    <div class="accordion-group">
                        <div class="accordion-heading">
                            <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion-1000" href="#accordion-element-<?php echo $emprestimo->id ?>" title="Informações detalhadas do empréstimo">
                                <i class="icon-map-marker"></i> #<?php echo "{$emprestimo->id} Empréstimo " . DbTable_Banco::getById($emprestimo->Banco_id)->nome . " " . DbTable_Filial::getById($emprestimo->Filial_id)->nome . " {$this->dataptbr($emprestimo->inicio)} {$emprestimo->parcelas}x"; ?>
                            </a>
                        </div>
                        <div id="accordion-element-<?php echo $emprestimo->id ?>" class="accordion-body collapse in">
                            <div class="accordion-inner">
                                <div class="row-fluid" >
                                    <div class="span8">
                                        <table class="table-hover" id="tb_emprestimo-show-info">
                                            <thead>
                                                <th></th>
                                                <th></th>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <td>#:</td>
                                                    <td><?php echo $emprestimo->id?></td>
                                                </tr>
                                                <tr>
                                                    <td>Banco:</td>
                                                    <td><?php echo DbTable_Banco::getById($emprestimo->Banco_id)->nome?></td>
                                                </tr>
                                                <tr>
                                                    <td>Filial:</td>
                                                    <td><?php echo DbTable_Filial::getById($emprestimo->Filial_id)->nome?></td>
                                                </tr>  
                                                <tr>
                                                    <td>Órgão:</td>
                                                    <td><?php echo $emprestimo->orgao?></td>
                                                </tr>                                                
                                                <tr>
                                                    <td>Valor Parcela:</td>
                                                    <td>R$ <?php echo $emprestimo->valor?></td>
                                                </tr>   
                                                <tr>
                                                    <td>Início:</td>
                                                    <td><?php echo $this->dataptbr($emprestimo->inicio)?></td>
                                                </tr>   
                                                <tr>
                                                    <td>Fim:</td>
                                                    <td><?php echo $this->dataptbr($emprestimo->fim)?></td>
                                                </tr>          
                                                <tr>
                                                    <td>Qtd. Anexos</td>
                                                    <td><?php echo DbTable_Anexo::getAnexos($emprestimo->Cliente_id, $emprestimo->id)->count(); ?>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="span3">
                                        <div class="row" style="margin-bottom: 15px">
                                            <div class="span12">
                                                <?php if ($this->session->role == Role::ADMINISTRADOR): ?>
                                                <a href="#modal-anexar-doc<?php echo $emprestimo->id?>" role="button" data-toggle="modal"><button class="btn btn-large btn-default" title="Anexar Documento" data-placement="left"><img src="<?php echo $this->baseUrl() ?>/public/img/anexo.png" width="30" height="30"/></button></a>
                                                <?php echo $this->partial('partials/anexar-doc-emprestimo.phtml', array('emprestimo' => $emprestimo)); ?>
                                                <p><a href="#modal-confirma-exclusao-emprestimo<?php echo $emprestimo->id ?>" role="button" data-toggle="modal" ><button style="margin-top: 15px" class="btn btn-large btn-default" title="Deletar Empréstimo" data-placement="left"><img src="<?php echo $this->baseUrl() ?>/public/img/excluir.png" width="30" height="30"/></button></a>                                                
                                                <?php echo $this->partial('partials/confirm-remove-emprestimo.phtml', array('emprestimo' => $emprestimo)); ?>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="span12">
                                                <a href="<?php echo $this->baseUrl() ?>/emprestimo/listar/cliente/<?php echo $emprestimo->Cliente_id ?>/emprestimo/<?php echo $emprestimo->id ?>" ><button class="btn btn-large btn-default" title="Listar Documentos" data-placement="left"><img src="<?php echo $this->baseUrl() ?>/public/img/arquivos.png" width="30" height="30"/></button></a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div> 
                
                <?php endforeach; ?>
                
            </div>
        </div>
        <div class="span2"></div>
    </div>
</div>


<?php echo $this->partial('partials/cadastrar-emprestimo.phtml', array('cliente' => $this->cliente, 'bancos' => $this->bancos, 'filiais' => $this->filiais)); ?>
